import Koa from 'koa'
import cors from '@koa/cors'
import koaBodyparser from 'koa-bodyparser'
import { errorHandler } from './middlewares/error-handler.js'

const app = new Koa()
import('./sockets/socket-events.js');

app.use(
  cors({
    origin: '*',
    methods: ['GET', 'POST'],
    headers: ['Content-Type'],
  })
)

app.use(koaBodyparser())
app.use(errorHandler)


const PORT = process.env.PORT || 3010
app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`)
})
